package cn.itcast.util;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * SequenceId生成器，生成的SeqId用来标记服务端和客户端之间请求的对应关系
 */
public class IdUtil {

    private static final AtomicInteger id = new AtomicInteger(0);

    public static Integer genId(){
        return id.getAndIncrement();
    }


    public static void main(String[] args) {
        Integer id1 = genId();
        Integer id2 = genId();
        Integer id3 = genId();

        System.out.println(id1);
        System.out.println(id2);
        System.out.println(id3);
    }
}
